HTTP Headers
-
HTTP header is a field(key:value) in an HTTP request or response that contains extra information about the request or response.
Header Types
1. Reqeust header
-
HTTP client uses this to provide information about the request context, so that the server can tailor the response.
Header Name | Content | ||||
---|---|---|---|---|---|
Accept request header |
MIME types HTTP client is able to understand.
|
||||
Authorization request header |
Provide credentials that authenticate a user agent with a server, allowing access to a protected resource
|
||||
Accept-Language |
natural language and locale that the client prefers
|
||||
Referer |
Absolute or partial address from which a resource has been requested
|
||||
Connection |
whether the network connection stays open after the current transaction finishes If the value sent is keep-alive, the connection is persistent and not closed, allowing for subsequent requests to the same server to be done.
|
||||
Upgrade-Insecure-Requests |
sends a signal to the server expressing the client's preference for an encrypted and authenticated response
|
||||
Fetch metadata request header |
- Provides additional information about the context from which the request originated. - This allows the server to make decisions about whether a request should be allowed based on where the request came - With this information a server can implement a resource isolation policy - This approach can help mitigate common cross-site web vulnerabilities such as CSRF, Cross-site Script Inclusion('XSSI'), timing attacks, and cross-origin information leaks - Forbidden header name: These headers are prefixed with Sec-, and hence have forbidden header names. A forbidden header name is the name of any HTTP header that cannot be modified programmatically(ie using javascript)
|
2. Response header
3. Representation header
-
describes one particular representation of a resource. Data might be present as XML, JSON, HTML
Header Name | Meaning | Content |
---|---|---|
Content-Type header |
Indicate the original media type(sound file might be labeled audio/ogg, or an image file image/png)
of the resource In requests, (such as POST or PUT), the client tells the server what type of data is actually sent. |
|
Content-Encoding header |
Tells any encodings that have been applied to the message payload. This lets the recipient know how to decode the representation in order to obtain the original payload format. |
|